﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

/// <summary>
/// Summary description for TGDDConfiguration
/// </summary>
public static class TGDDConfiguration
{
    // Caches the connection string
    private static string dbConnectionString;
    // Caches the data provider name 
    private static string dbProviderName;
    private readonly static int productsPerPage;
    // Store the product description length for product lists
    private readonly static int productDescriptionLength;
    private readonly static int noiDungTinTucLength;
    // Store the name of your shop
    private readonly static string siteName;
    // Store the number of days for shopping cart expiration
    private readonly static int cartPersistDays;
    private readonly static int fixSize;
    private readonly static int fixSizeList;

    static TGDDConfiguration()
	{
        dbConnectionString = ConfigurationManager.ConnectionStrings["TGDDConnectionString"].ConnectionString;
        dbProviderName = ConfigurationManager.ConnectionStrings["TGDDConnectionString"].ProviderName;
        productsPerPage = Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]);
        productDescriptionLength = Int32.Parse(ConfigurationManager.AppSettings["ProductDescriptionLength"]);
        noiDungTinTucLength = Int32.Parse(ConfigurationManager.AppSettings["NoiDungTinTucLength"]);
        siteName = ConfigurationManager.AppSettings["SiteName"];
        fixSize = int.Parse(ConfigurationManager.AppSettings["FixSize"]);
        fixSizeList = int.Parse(ConfigurationManager.AppSettings["FixSizeList"]);
        cartPersistDays =
            Int32.Parse(ConfigurationManager.AppSettings["CartPersistDays"]);
    }

    public static int NoiDungTinTucLength
    {
        get
        {
            return noiDungTinTucLength;
        }
    }
    // Returns the number of days for shopping cart expiration
    public static int CartPersistDays
    {
        get
        {
            return cartPersistDays;
        }
    }

    // Returns the connection string for the BalloonShop database
    public static string DbConnectionString
    {
        get
        {
            return dbConnectionString;
        }
    }

    // Returns the maximum number of products to be displayed on a page
    public static int ProductsPerPage
    {
        get
        {
            return productsPerPage;
        }
    }

    // Returns the length of product descriptions in products lists
    public static int ProductDescriptionLength
    {
        get
        {
            return productDescriptionLength;
        }
    }

    // Returns the address of the mail server
    public static string MailServer
    {
        get
        {
            return ConfigurationManager.AppSettings["MailServer"];
        }
    }

    // Send error log emails?
    public static bool EnableErrorLogEmail
    {
        get
        {
            return bool.Parse(ConfigurationManager.AppSettings["EnableErrorLogEmail"]);
        }
    }

    // Returns the email address where to send error reports
    public static string ErrorLogEmail
    {
        get
        {
            return ConfigurationManager.AppSettings["ErrorLogEmail"];
        }
    }

    // Returns the length of product descriptions in products lists
    public static string SiteName
    {
        get
        {
            return siteName;
        }
    }

    // Returns the data provider name
    public static string DbProviderName
    {
        get
        {
            return dbProviderName;
        }
    }

    public static int FixSize
    {
        get { return fixSize; }
    }

    public static int FixSizeList
    {
        get { return fixSizeList; }
    }
}
